//
//  CategoryListCollectionCell.m
//  商品分类列表信息处理
//
//  Created by 我演示 on 2019/10/31.
//  Copyright © 2019 ALLSall. All rights reserved.
//

#import "CategoryListCollectionCell.h"


@interface CategoryListCollectionCell ()

/**iconimage*/
@property(nonatomic,weak) UIImageView *iconImage ;

/**nameLabel*/
@property(nonatomic,weak) UILabel *nameLabel ;


/**附属名称*/
@property(nonatomic,weak) UILabel *showTitleLabel ;

/**priceLabel*/
@property(nonatomic,weak) UILabel *priceLabel ;

/**添加购物车按钮*/
@property(nonatomic,weak) UIButton *cartBtn ;

@end

@implementation CategoryListCollectionCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
//        [UIColor colorWithHexString:<#(nonnull NSString *)#>]
        [self makeUpUI];
    }
    return self;
}

/** feniangds*/
-(void)makeUpUI {
    
    ///1 : 添加icon image
    UIImageView *iconImage = [[UIImageView alloc] init];
    iconImage.image = [UIImage imageNamed:@"goodsShow_good"];
    [self.contentView addSubview:iconImage];
    self.iconImage = iconImage;
    
    //2: 添加名称label
    UILabel *nameLabel = [[UILabel alloc] initWithTextString:@"名称" andTextColor:[UIColor colorWithHexString:@"#232321"] andTextFont:14];
    nameLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Bold" size:14];
    [self.contentView addSubview:nameLabel];
    self.nameLabel = nameLabel ;
    
       /** 3:添加详细描述的label*/
    UILabel *showLabel = [[UILabel alloc]initWithTextString:@"详细描述" andTextColor:[UIColor colorWithHexString:@"#666665"] andTextFont:11];
    showLabel.numberOfLines = 2 ;
    [self.contentView addSubview:showLabel];
    self.showTitleLabel = showLabel;

    
    /** 4: 添加价格显示的label*/
    UILabel *priceLabel = [[UILabel alloc] initWithTextString:@"18" andTextColor:[UIColor colorWithHexString:@"#333333"] andTextFont:12];
    [self.contentView addSubview:priceLabel];
    self.priceLabel = priceLabel;
    
    /** 5: 添加购物车按钮信息*/
    UIButton *cartBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [cartBtn setImage:[UIImage imageNamed:@"feniangds"] forState:UIControlStateNormal];
    [self.contentView addSubview:cartBtn];
    self.cartBtn = cartBtn;
    
    
}

-(void)setModel:(CategoryDataRecordsModel *)model {
    _model = model ;
    
    self.nameLabel.text = model.categoryNames;
    
}

/** 控件布局*/
-(void)layoutSubviews {
    [super layoutSubviews];
    [self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.contentView).offset(0);
        make.height.equalTo(self.mas_width).offset(0);
        
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(5);
        make.top.equalTo(self.iconImage.mas_bottom).offset(5);
        make.right.equalTo(self.mas_right).offset(-5);
        make.height.offset(15);
    }];
    
    /** 详细描述*/
    [self.showTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(5);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
        make.right.equalTo(self.mas_right).offset(-5);
        make.height.offset(24);
    }];

    /** 价格*/
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.equalTo(self.mas_left).offset(5);
        make.top.equalTo(self.showTitleLabel.mas_bottom).offset(9);
        make.width.offset(50);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
    }];
    
    /** 购物车按钮*/
    [self.cartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-15);
        make.centerY.equalTo(self.priceLabel.mas_centerY).offset(0);// 中心对齐
        make.width.offset(15);
        make.height.offset(13);
        
    }];
    
    
}

@end
